<?php
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
if($_RQ['op']=='list'){
	$pindex = max(1, intval($_SESSION['page']));
	$psize = 15;
	$params=array('uniacid'=>$_SESSION['uniacid'],'cid >'=>0);
    $fields=array('id','cid','status','uid','likenum','content');
    $orderby='id desc';
	$total='';
	$return['list']=pdo_getslice('jy_cmsarticle_comments',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	foreach($return['list'] as &$item){
		$item['cid']=pdo_getcolumn('jy_cmsarticle_news',array('id'=>$item['cid']),'title');	
		$item['cid']=$item['cid']?$item['cid']:'无';
		$item['member']=cfc('core')->member_show($item['uid']);
	}
	$return['status']=array('0'=>'隐藏','1'=>'显示');
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'list','title'=>'评论管理'),
		),
		'list'=>array('data'=>'list','list'=>array(
			'0'=>array('name'=>'cid','title'=>'文章名称','type'=>'string'),
			'1'=>array('name'=>'member','title'=>'评论人','type'=>'member'),
			'2'=>array('name'=>'content','title'=>'内容','type'=>'string'),
			'3'=>array('name'=>'likenum','title'=>'点赞数','type'=>'string'),
			'3'=>array('name'=>'status','title'=>'状态','type'=>'radio','options'=>'status'),
		),
		
		),
	);
	$return['htmls']=$htmls;
	exi($return);
	}
	if($_RQ['op']=='edit'){
	$id=intval($_RQ['id']);
	if($id){
	$item=pdo_get('jy_cmsarticle_comments',array('id'=>$id));
	}else{
		$item=array();
	}
	
    $return['item']=$item;
	
	$htmls=array(
		'type'=>'edit',
		'post'=>'post',
		'desc'=>'',
		'tabs'=>array(
			array('op'=>'list','title'=>'评论管理'),
			
		),
		'edit'=>array(
			array('name'=>'status','title'=>'状态','type'=>'radio','options'=>'status'),
		//	array('name'=>'likenum','title'=>'点赞数','type'=>'string'),
		//	array('name'=>'paixu','title'=>'排序','type'=>'string','help'=>'越大越靠前'),
			)
			);
	$return['status']=array('0'=>'隐藏','1'=>'显示');
	$return['htmls']=$htmls;
	exi($return);
	}
	if($_RQ['op']=='post'){
	$postdata=get_postdata();
	$data=array_fields(array('status'),$postdata);
	$id=intval($postdata['id']);
			if($id){
				pdo_update('jy_cmsarticle_comments',$data,array('id'=>$id));
				exi('设置成功！','','list');
			}else{
				exi('请先选择评论','error','list');
			}
			}
	if($_RQ['op']=='del'){

	$id=intval($_RQ['id']);
	if($id){
		pdo_delete('jy_cmsarticle_comments',array('id'=>$id));	
	}
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
		foreach($del as $id){
			$id=intval($id);
			if($id){
				pdo_delete('jy_cmsarticle_comments',array('id'=>$id));
			}
		}
	}
	exi('删除成功！');
}
?>